package com.example.module_home.DB;

import android.content.Context;

import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;
import java.util.TreeSet;

/**
 * Created by 陈煜 on 2018/5/30.
 */

public class DBOperationHelper<D> {
    private Dao<D,Integer> mDao;
    public DBOperationHelper(Context context,Class<D> dataClass) throws SQLException {
        DBOrmLiteHelper dbOrmLiteHelper = DBOrmLiteHelper.getInstance(context);
        dbOrmLiteHelper.onCreateTable(dataClass);
        mDao = dbOrmLiteHelper.getDao(dataClass);
    }

    public void insertData(D d) throws SQLException {
        mDao.create(d);
        
    }

    public List<D> queryAll() throws SQLException {
        List<D> ds = mDao.queryForAll();
        return ds;
    }

}
